<?php
session_start();//开启session
?>
<!DOCTYPE html>
<html>
    <head>
        <title>设置头像</title>
        <meta charset="utf-8" />
        <link type="text/css" rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" />
        <script type="text/javascript" src="../bootstrap/js/jquery-1.9.1.min.js"></script>
        <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
        <style type="text/css">
            .panel{
	            width: 400px;
            	height: 300px;
            	margin: auto;
            }
            .form-group span{
	            display: block;
            	height: 20px;
            	color: red;
            }
            #file{
	            cursor: pointer;
            }
        </style>
        <script type="text/javascript">
        $(function(){
            $("#file").click(function(){
                $("#fileUpload").click();
            });
            $("#fileUpload").change(function(){
                var extName = this.value.substr(this.value.lastIndexOf("."));
                if(extName == ".jpg" || extName == ".png" || extName==".gif" || extName==".jpeg" || 
                		extName == ".JPG" || extName == ".PNG" || extName==".GIF" || extName==".JPEG"){
                	$("#file").val(this.value);
                }else{
                    alert("请选择图片文件！");
                }
            });      
        });
        </script>
    </head>
    <body>
        <br/><br/><br/><br/>
        <br/><br/><br/>
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">设置头像</h3>
            </div>
            <div class="panel-body">
                <form action="../index.php" method="post" enctype="multipart/form-data">
                    <input type="hidden" name="c" value="User"/>
                    <input type="hidden" name="a" value="setHead"/>
                    <div class="form-group">
                        <label>用户名</label>
                        <input type="file" name="headPicture" id="fileUpload" style="display:none;" />
                        <input type="text" id="file" class="form-control" readonly placeholder="设置头像" />
                        <span></span>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">确认</button>
                    </div>
                </form>
            </div>
        </div>
    </body>
</html>